package com.shishuo.cms.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.shishuo.cms.dao.RoleDao;
import com.shishuo.cms.entity.RoleEntity;
import com.shishuo.cms.entity.vo.PageVo;

@Service
public class RoleService extends BaseService<RoleEntity, Integer> {

	private RoleDao roleDao;

	@Autowired
	public void setRoleDao(RoleDao roleDao) {
		setBaseDao(roleDao);
		this.roleDao = roleDao;
	}

	public List<RoleEntity> getRoles(int status) {
		return roleDao.getRoles(status);
	}

	public int updateRoleStatus(int id, int status) {
		return roleDao.updateRoleStatus(id, status);
	}

	public PageVo<RoleEntity> getAllListPage(int pageNum) throws Exception {
		PageVo<RoleEntity> pageVo = new PageVo<RoleEntity>(pageNum);
		List<RoleEntity> list = this.getAllList(pageVo.getOffset(), pageVo.getRows());
		pageVo.setList(list);
		pageVo.setCount(this.getAllListCount());
		return pageVo;
	}
}
